//
//  HXSelecedMadeCell.m
//  ZCooking
//
//  Created by 韩旭 on 16/9/1.
//  Copyright © 2016年 HX_. All rights reserved.
//

#import "HXSelecedMadeCell.h"
#import "HXSelectCollectionCell.h"
#import "HX_Macro.h"
#import "UIView+Frame.h"
#import "UIImageView+WebCache.h"
#import "HXCustomModel.h"
#import "HXCustomTitlesModel.h"
#define kSelected @"reuseSelect"
@implementation HXSelecedMadeCell
- (void)setArrImage:(NSMutableArray *)arrImage {
    _arrImage = arrImage;
    [_collectionView reloadData];
}
- (void)setArrTitles:(NSMutableArray *)arrTitles {
    _arrTitles = arrTitles;
}
- (void)setUp {
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
    layout.minimumLineSpacing = 0;
    layout.scrollDirection = 1;
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    _collectionView.backgroundColor = [UIColor redColor];
    [self.contentView addSubview:_collectionView];
    [_collectionView registerNib:[UINib nibWithNibName:@"HXSelectCollectionCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:kSelected];
    [self creatViewLine];
}
- (void)creatViewLine {
    self.viewBack = [[UIView alloc] initWithFrame:CGRectZero];
    _viewBack.backgroundColor = [UIColor colorWithRed:0.88 green:0.88 blue:0.88 alpha:1.00];
    [self.contentView addSubview:_viewBack];
    self.lableDetail = [[UILabel alloc] initWithFrame:CGRectZero];
    _lableDetail.textAlignment = 1;
     _lableDetail.font = [UIFont systemFontOfSize:12];
    _lableDetail.textColor = [UIColor colorWithWhite:0.742 alpha:1.000];
    _lableDetail.backgroundColor = [UIColor whiteColor];
    [self.viewBack addSubview:_lableDetail];
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 3;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    HXSelectCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:kSelected forIndexPath:indexPath];
    cell.backgroundColor = [UIColor whiteColor];
    cell.NameLabel.text = [self.arrTitles[indexPath.row] text];
    if (indexPath.row == 0) {
        [cell.imageHeader sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[0] image]]]];
        [cell.PersonImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[1] image]]]];
    } else if (indexPath.row == 1) {
        [cell.imageHeader sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[2] image]]]];
        [cell.PersonImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[3] image]]]];
    } else {
        [cell.imageHeader sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[4] image]]]];
        [cell.PersonImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@", [self.arrImage[5] image]]]];
    }
    return cell;
}
- (void)layoutSubviews {
    [super layoutSubviews];
    self.collectionView.frame = CGRectMake(0, 0, self.contentView.HX_width, self.contentView.HX_height - 50);
    _viewBack.frame = CGRectMake(0, self.collectionView.HX_height, self.collectionView.HX_width, 50);
     _lableDetail.frame = CGRectMake(0, 0, self.collectionView.HX_width, 35);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section {
    return 0;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section {
    return 0;
}
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {

    return CGSizeMake(self.collectionView.HX_width / 3, self.collectionView.HX_height);
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    self.item(indexPath.row);
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
